import request from '@/utils/request'

/* 获取所有员工的接口 */
export const fetchEmployeeListAPI = (pageParams) => {
  return request({
    url: '/employee/page',
    method: 'GET',
    params: pageParams
  })
}
/* 删除员工的接口 */
export const deleteEmployeeAPI = (id) => {
  return request({
    url: `/employee/${id}`,
    method: 'DELETE'
  })
}
/* 更新员工状态的接口 */
export const updateStatusAPI = (status, id) => {
  return request({
    url: `/employee/status/${status}`,
    method: 'POST',
    params: {
      id
    }
  })
}

/* 根据ID查询员工的接口 */
export const fetchEmployeeDetailAPI = (id) => {
  return request({
    url: `/employee/${id}`,
    method: 'GET'
  })
}

/* 添加或者编辑员工的接口 */
export const addOrUpdateEmployeeAPI = (data) => {
  if (data.id) {
    return request({
      url: '/employee',
      method: 'PUT',
      data
    })
  } else {
    return request({
      url: '/employee',
      method: 'POST',
      data
    })
  }
}
